package its.opt.structures;

public class IntStack {
	private int maxSize;
	private int size;
	private int[] s;

	public IntStack(int max) {
		maxSize = max;
		size = 0;

		s = new int[max];
	}

	public int push(int x) {
		if (size >= maxSize) {
			throw new IllegalArgumentException("Push method called for a full stack!");
		}

		return s[size++] = x;
	}

	public int pop() {

		if (size > 0)
			return s[--size];
		else {
			throw new IllegalArgumentException(
					"ERROR: pop method called for an empty stack!");
		}
	}

	public boolean empty() {
		return (size == 0);
	}

	public boolean notEmpty() {
		return !empty();
	}

	public boolean full() {
		return (size == maxSize);
	}

	public int getSize() {
		return size;
	}
}
